from common.equipment.weapon import Weapon


def create_weapon(key, meta: dict, quality=None):
    weapon = Weapon(key, **meta)
    if quality is not None and isinstance(quality, str):
        weapon.quality = quality

    return weapon


__methods = {
    'weapon': create_weapon
}


def create_equip(key, meta: dict, quality=None):
    category: str = meta['slot']
    if category not in __methods:
        return None

    return __methods[category](key, meta, quality)
